namespace HelpDesk.Migrations
{
    using HelpDesk.Models;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using System.Web.Security;
    using WebMatrix.WebData;

    internal sealed class Configuration : DbMigrationsConfiguration<HelpDesk.Models.HelpDeskDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(HelpDesk.Models.HelpDeskDbContext context)
        {
            

            if (!Roles.RoleExists("Administrator"))
                Roles.CreateRole("Administrator");

            if (!Roles.RoleExists("Customer"))
                Roles.CreateRole("Customer");

            if (!Roles.RoleExists("SupportStaff"))
                Roles.CreateRole("SupportStaff");


            if (!WebSecurity.UserExists("admin"))
                WebSecurity.CreateUserAndAccount(
                    "admin",
                    "admin",
                    new { Mobile = "+19725000000", IsSmsVerified = false });

            if (!Roles.GetRolesForUser("admin").Contains("Administrator"))
                Roles.AddUsersToRoles(new[] { "admin" }, new[] { "Administrator" });



            //context.Tickets.Add(new Ticket
            //{
            //    TicketID = 1,
            //    Title = "First Ticket",
            //    Description = "Computer Broke",
            //    Customer = new UserProfile { UserId = 3, UserName = "ernie" },
            //    SupportStaff = new UserProfile { UserId = 1, UserName = "ebr1181" },
            //    Priority = Ticket.TicketPriority.High,
            //    Status = Ticket.TicketStatus.Open

            //});
            //context.SaveChanges();

            //context.Tickets.Add(new Ticket
            //{
            //    TicketID = 2,
            //    Title = "Second Ticket",
            //    Description = "Application Broke",
            //    Customer = new UserProfile { UserId = 3, UserName = "eruiz" },
            //    SupportStaff = new UserProfile { UserId = 1, UserName = "ebr1181" },
            //    Priority = Ticket.TicketPriority.Medium,
            //    Status = Ticket.TicketStatus.Closed

            //});

            context.SaveChanges();
        }
    }
}
